package com.linkage.educloud.ah.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mr'Tang on 2018/12/19.
 */

public class HomeResBean {
// "year":"2018",
// "resname":"语文",
// "resurl":"http://221.130.6.212:4887/educloud/resource/zhyk/h5/zhykDetail",
// "resicon":"http://221.130.6.212:4887/educloud_share/hfyz/static/jpg/20180523/img7227.jpg",
// "sign":"重难点讲解,解题技巧,专题课程",
// "resid":7227,
// "readnum":15}

    private String year;
    private String resname;
    private String resurl;
    private String resicon;
    private String sign;
    private int resid;
    private int readnum;

    public static List<HomeResBean> parseFromJson(JSONArray jsonArray) {
        List<HomeResBean> list = new ArrayList<>();
        for (int a = 0; a < jsonArray.length(); a++) {
            HomeResBean bean = new HomeResBean();
            JSONObject jsonObj = null;
            try {
                jsonObj = jsonArray.getJSONObject(a);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            bean.setYear(jsonObj.optString("year"));
            bean.setResname(jsonObj.optString("resname"));
            bean.setResurl(jsonObj.optString("resurl"));
            bean.setResicon(jsonObj.optString("resicon"));
            bean.setSign(jsonObj.optString("sign"));
            bean.setResid(jsonObj.optInt("resid"));
            bean.setReadnum(jsonObj.optInt("readnum"));
            list.add(bean);
        }
        return list;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getResname() {
        return resname;
    }

    public void setResname(String resname) {
        this.resname = resname;
    }

    public String getResurl() {
        return resurl;
    }

    public void setResurl(String resurl) {
        this.resurl = resurl;
    }

    public String getResicon() {
        return resicon;
    }

    public void setResicon(String resicon) {
        this.resicon = resicon;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public int getResid() {
        return resid;
    }

    public void setResid(int resid) {
        this.resid = resid;
    }

    public int getReadnum() {
        return readnum;
    }

    public void setReadnum(int readnum) {
        this.readnum = readnum;
    }
}
